package com.zeng.test;

import com.zeng.bean.Car;
import com.zeng.config.MainConfig2;
import com.zeng.config.MyConfigOfLifeCycle;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.Arrays;

/**
 * @author Zqm
 * @Title: IOCTest_LifeCycle
 * @ProjectName SpringAnnotationDriven
 * @date 2019/1/14
 */
public class IOCTest_LifeCycle {

    /**
     * 创建容器
     */
    AnnotationConfigApplicationContext applicationContext=new AnnotationConfigApplicationContext(MyConfigOfLifeCycle.class);

    private void printBeans(ApplicationContext applicationContext){
        String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();
        Arrays.asList(beanDefinitionNames).stream().forEach(s -> System.out.println("容器所有的bean......"+s));

    }


    @Test
    public void test01(){
        printBeans(applicationContext);

        applicationContext.getBean(Car.class);
        applicationContext.close();
    }
}
